#!/bin/bash
catch_ip(){
  if [[ "$1" =~ ([0-9]\.){3}([0-9]) ]]
  then
    #echo ${BASH_REMATCH}
    return 1
  fi
  return 0
}
tmp_file=ip.tmp
rm -f $tmp_file
for line in $(cat ip_test.txt)
do
  catch_ip $line
  if [[ "$?" -eq "1" ]]
  then
    echo ${BASH_REMATCH} >> $tmp_file
  fi
done

cat $tmp_file|sort|uniq -c |sort -k 1 -r
rm -f $tmp_file
